home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Drawing
/
QDPatchBlock.cp
< prev
next >
Wrap
Text File
|
1997-06-28
|
2KB
|
82 lines
// QDPatchBlock.cp
#ifndef QDPatchBlock_h
#include "QDPatchBlock.h"
#endif
#ifndef GrafPortObject_h
#include "GrafPortObject.h"
#endif
const QDProcs& QDPatchBlock::MakeStandard()
{
static QDProcs standard;
SetStdProcs( &standard );
return standard;
}
const QDProcs& QDPatchBlock::Standard()
{
static const QDProcs& standard( MakeStandard() );
return standard;
}
QDPatchBlock::QDPatchBlock( GrafPortObject& thePort )
: QDProcs( Standard() ),
port( thePort )
{
Assert( port.grafProcs == 0 );
port.grafProcs = this;
}
QDPatchBlock::~QDPatchBlock()
{
Assert( port.grafProcs == this );
port.grafProcs = 0;
}
void QDPatchBlock::ActivateTextPatch()
{
Assert( textProc == Standard().textProc );
textProc = MyTextProc;
}
void QDPatchBlock::DeactivateTextPatch()
{
Assert( textProc == MyTextProc );
textProc = Standard().textProc;
}
pascal void QDPatchBlock::MyTextProc( int16 length,
int8 *text,
Point numerator,
Point denominator )
{
A5 oldA5;
GrafPort *thePort = **reinterpret_cast<GrafPort ***>( oldA5.Address() );
QDPatchBlock *self = static_cast<QDPatchBlock *>( thePort->grafProcs );
self->a5.Restore();
Assert( thePort != 0 );
Assert( thePort->grafProcs != 0 );
Assert( &self->port == thePort );
self->portA5 = oldA5;
self->DrawText( ConstData( text, length ),
numerator,
denominator );
oldA5.Restore();
}
void QDPatchBlock::DrawText( ConstData text,
Point numerator,
Point denominator )
{
portA5.Restore();
StdText( text.Length(), text.Start(), numerator, denominator );
a5.Restore();
}